﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


namespace WebLicenseGenerator.UC
{
	public enum ConfirmationResult
	{
		Yes = 1,
		No = 2
	}

	public class ConfirmationEventArgs
	{
		ConfirmationResult _result;
		public ConfirmationResult Result
		{
			get { return _result; }
			set { _result = value; }
		}

		public ConfirmationEventArgs(ConfirmationResult result)
		{
			_result = result;
		}
	}

	public partial class Confirmation : System.Web.UI.UserControl
	{
		public event ConfirmationEventHandler OnConfirmation;
		public delegate void ConfirmationEventHandler(object sender, ConfirmationEventArgs e);

		public string Title
		{
			get { return lblConfirmationTitle.Text; }
			set { lblConfirmationTitle.Text = value.ToUpper(); }
		}
		
		public string Message
		{
			get { return lblConfirmationMessage.Text; }
			set { lblConfirmationMessage.Text = value; }
		}

        protected void Page_Load(object sender, EventArgs e)
        {
		}

		protected void btYes_Click(object sender, EventArgs e)
		{
			if (OnConfirmation != null)
				OnConfirmation(this, new ConfirmationEventArgs(ConfirmationResult.Yes));

			this.HideConfirmationDialog();
		}

		protected void btNo_Click(object sender, EventArgs e)
		{
			if (OnConfirmation != null)
				OnConfirmation(this, new ConfirmationEventArgs(ConfirmationResult.No));

			this.HideConfirmationDialog();
		}

		public void ShowConfirmationDialog()
		{
			mpe.Show();
		}

		public void HideConfirmationDialog()
		{
			mpe.Hide();
		}
	}
}